<template>
  <van-pull-refresh v-model="isRefreshLoading" @refresh="onLoad">
    <MyEmpty v-if="isLoading === false && list.length === 0" />
    <van-list
      class="my-resume-list"
      v-model="isLoading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
      v-else
    >
      <div
        class="item"
        v-for="(item, index) in list"
        :key="index"
        @click="toViewResume(item.resumeid, 0)"
      >
        <div class="show">
          <div class="person">
            <img :src="item.logo" alt="" v-if="item.logo != ''" />
            <template v-else>
              <img
                src="@/assets/img/my/no-avatar-boy.png"
                alt=""
                v-if="item.sex === '男'"
              />
              <img src="@/assets/img/my/no-avatar-girl.png" alt="" v-else />
            </template>
            <p>
              <b>{{ item.name }}</b>
              <span>{{ item.showDate }}</span>
            </p>
            <p>
              <span v-if="item.area != ''">{{ item.area }}</span>
              <span>{{ item.age }}岁</span>
              <span>{{ item.edu }}</span>
              <span>{{ item.workyear }}</span>
            </p>
          </div>
          <div class="expect" v-if="item.jobWantedMonthPay != ''">
            <span>{{ item.jobWantedMonthPay }}</span>
            <span>{{ item.jobWantedJob }}</span>
          </div>
        </div>
      </div>
    </van-list>
  </van-pull-refresh>
</template>

<script>
import { List, Button, SwipeCell, PullRefresh } from "vant";
import MyEmpty from "@/components/MyEmpty.vue";
import { CompanyResumeRecommendResume } from "@/util/http";
import { mixin_company_common } from "@/mixin/mixins";
export default {
  name: "RecommendResume",
  components: {
    MyEmpty,
    [List.name]: List,
    [Button.name]: Button,
    [SwipeCell.name]: SwipeCell,
    [PullRefresh.name]: PullRefresh,
  },
  mixins: [mixin_company_common],
  mounted() {
    this.onLoad();
  },
  // 定义属性
  data() {
    return {
      isRefreshLoading: false,
      list: [],
      isLoading: true,
      finished: false,
    };
  },
  // 方法集合
  methods: {
    onLoad() {
      CompanyResumeRecommendResume().then((res) => {
        // console.log(res);
        this.isLoading = false;
        if (this.isRefreshLoading) {
          this.list = [];
        }
        this.isRefreshLoading = false;
        let list = res;
        if (list.length > 0) {
          this.list = [...this.list, ...list];
          this.finished = true;
        }
      });
    },
  },
};
</script>

<style scoped></style>
